﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.CompilerServices;

namespace BE.Configuracion
{
    [assembly: InternalsVisibleTo("BC")]
    public class ModuloBE
    {
        public int? iModuleId{get;set;}
		public string sModuleName{get;set;}
		public string sDescription{get;set;}
        public bool bActive { get; set; }

        internal List<ModuloBE> Select()
        {
            List<ModuloBE> result = new List<ModuloBE>();
            try
            {
                using (DAL.Configuration.ModulosDAL<ModuloBE> datos = new DAL.Configuration.ModulosDAL<ModuloBE>())
                {
                    result = datos.GetList();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("BE.Configuracion - ModuloBE - Select - ", ex);
            }
            return result;
        }
        internal void Create()
        {
            try
            {
                ModuloBE item = new ModuloBE();
                using (DAL.Configuration.ModulosDAL<ModuloBE> datos = new DAL.Configuration.ModulosDAL<ModuloBE>())
                {
                    item = datos.Create(this.sModuleName, this.sDescription);
                }
                if (item.iModuleId != -1)
                {
                    this.iModuleId = item.iModuleId;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("BE.Configuracion - ModuloBE - Create - ", ex);
            }
        }
        internal void Update()
        {
            try
            {
                ModuloBE item = new ModuloBE();
                using (DAL.Configuration.ModulosDAL<ModuloBE> datos = new DAL.Configuration.ModulosDAL<ModuloBE>())
                {
                    item = datos.Update((int)this.iModuleId,this.sModuleName, this.sDescription);
                }
                if (item.iModuleId != -1)
                {
                    this.iModuleId = item.iModuleId;
                    this.sModuleName = item.sModuleName;
                    this.sDescription = item.sDescription;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("BE.Configuracion - ModuloBE - Update - ", ex);
            }
        }

    }
}
